﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;

using Haushaltsbuch.DataAcces.Entities;

namespace Haushaltsbuch.DataAcces
{
    public class HaushaltsbuchContext : DbContext
    {
        public DbSet<User> Users { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Shop> Shops { get; set; }

        public HaushaltsbuchContext()
        {
            this.Configuration.LazyLoadingEnabled = false;
            this.Configuration.ProxyCreationEnabled = false;
        }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity<User>()
                        .HasMany(u => u.Roles)
                        .WithMany();
        }


    }
}